package 进阶.lambda表达式.练习;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class demo_Person {
    public static void main(String[] args) {
        Person[] people = {new Person("jack",18),
                        new Person("rose",19),
                new Person("rose",20)
        };

        /*Arrays.sort(people, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getAge() - o2.getAge();
            }
        });*/

        Arrays.sort(people,(Person o1, Person o2) -> {
            return o1.getAge() - o2.getAge();
        });
        for (Person i:people
             ) {
            System.out.println(i);
        }
    }
}
